<?php $this->load->view('layout/header'); ?>

<form name="form1" method="post" action="<?php echo B_URL; ?>/file" id="form1">
    <div id="container">
        <!--导航开始-->
        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="table_file_form">
            <tr>
                <td style="width: 10%;">
                    文件路径：
                </td>
                <td align="left" style="width: 40%;">
                    <select name="drpFolderPath" id="drpFolderPath" onchange="SelectFolder()" style="width:90%;">
                        <?php
                        $p_list = explode('/', $path);
                        $len = count($p_list);
                        $temp = '';
                        foreach ($p_list as $k => $v) {
                            $temp.=$v . '/';
                            ?>
                        <option value="<?php echo $temp; ?>" <?php echo $len-1 == $k ?'selected="selected"':''?>><?php echo $temp; ?></option>
                            <?php
                        }
                        ?>
                    </select>
                </td>
                <td style="width: 10%;">
<!--                   // 搜索文件：-->
                </td>
                <td align="left" style="width: 40%;">
<!--                    <input name="txtFileNameKey" type="text" id="txtFileNameKey" />
                    <input type="hidden" name="hidIsSearch" id="hidIsSearch" value="1" />
                    <input type="submit" name="btnQuery" value="查询" id="btnQuery" />-->
                </td>
            </tr>
        </table>
        <!--导航结束-->
        <!--操作选项开始-->
        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="table_op">
            <tr>
                <td>
                    操作选项：
                    <a href="javascript:createFolder()">创建文件夹</a>
                    <a onclick="checkDelFolder(this);" name="FileName" href="javascript:void(0)">删除所选文件(夹)</a>
                    <a href="javascript:void(0);" onclick="upload_file()">上传文件</a>
                </td>
            </tr>
        </table>
        <!--操作选项结束-->
        <!--列表开始-->
        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="table_list" id="TbList">
            <tr class="table_list_title">
                <td style="width: 2%">
                    <input type="checkbox" name="checkbox" value="" onclick="javascript:checkAll(this, 'FileName');" />
                </td>
                <td style="width: 5%">
                    类型
                </td>
                <td style="width: 10%">
                    名称<span class="red">(点击文件名选择)</span>
                </td>
                <td style="width: 10%">
                    数量/大小
                </td>
                <td style="width: 10%">
                    权限
                </td>
                <td style="width: 10%">
                    创建时间
                </td>
            </tr>
            <?php 
            
            foreach ($dir_list as $k => $v) { 
                $file_path = $default_file.$path . '/' . $v;
                $is_dir = is_dir($file_path);
                if ($is_dir) {
                    ?>
                    <tr class="table_list_row_normal">
                        <td style="width: 2%">
                            <input name="FileName" type="checkbox" id="FileName" value="<?php echo $v;?>" />
                        </td>         
                        <td style="width: 5%">
                            <img src="/static/bk/fileImages/folder.gif" width="16" height="16" alt="文件夹" />
                        </td>
                        <td style="width: 10%" align="left">
                            <a href="?doc_id=<?php echo $_GET['doc_id'];?>&path=<?php echo $path . '/' . $v;?>" title="点击选择">
                                <?php echo $v; ?>
                            </a>
                        </td>
                        <td style="width: 10%">
                            <?php echo count(scandir($file_path)) - 2; ?>
                        </td>
                        <td style="width: 10%">
                            <?php echo substr(base_convert(@fileperms($file_path), 10, 8), -4); ?>
                        </td>
                        <td style="width: 10%">
                            <?php echo date('Y-m-d H:i:s', filemtime($file_path)); ?>
                        </td>
                    </tr>
                    <?php
                } else {
                    $name = substr($v, strrpos($v, '.') + 1);
                    ?>
                    <tr class="table_list_row_normal">
                        <td style="width: 2%">
                            <input name="FileName" type="checkbox" id="FileName" value="<?php echo $v;?>" />
                        </td>
                        <td style="width: 5%">
                            <img src="/static/bk/fileImages/<?php echo $name; ?>.gif" width="16" height="16" alt="<?php echo $name; ?>文件" />
                        </td>
                        <td style="width: 10%" align="left">
                            <a href="javascript:selectfile('<?php echo $_GET['doc_id'];?>','<?php echo substr($file_path, 1);?>');" title="点击选择">
                                <?php echo $v; ?>
                            </a>
                            <a href="#" onclick="javascript:show_pic('#show_<?php echo $k;?>');">预览</a>
                            <div id="show_<?php echo $k;?>" style="display:none;"><img src="<?php echo substr($file_path, 1);?>" /></div>
                        </td>
                        <td style="width: 10%">
                            <?php echo round(filesize($file_path)/1024,2); ?>KB
                        </td>
                        <td style="width: 10%">
                            <?php echo substr(base_convert(@fileperms($file_path), 10, 8), -4); ?>
                        </td>
                        <td style="width: 10%">
                            <?php echo date('Y-m-d H:i:s', filemtime($file_path)); ?>
                        </td>
                    </tr>
                <?php } ?>
            <?php } ?>

        </table>
        <!--列表结束-->
        <!--分页开始-->
        <div id="pager">
            共<b><?php echo $pagecount; ?></b>页 

            第<b><?php echo $page; ?></b>页 
            <b><?php echo $pagesize; ?></b>条/页 
            共<b><?php echo $count; ?></b>条记录

            <?php if ($page == 1) { ?>
                <span>首页 上一页</span>
            <?php } else { ?>
                <span><a href="/admin.php/file?path=<?php echo $path;?>&page=1">首页</a> 
                    <a href="/admin.php/file?path=<?php echo $path;?>&page=<?php echo $page - 1 ?>">上一页</a> </span>
            <?php } ?>
            <?php if ($page == $pagecount) { ?>
                <span>下一页 尾页</span>
            <?php } else { ?>
                <span><a href="/admin.php/file?path=<?php echo $path;?>&page=<?php echo $page + 1 ?>">下一页</a> 
                    <a href="/admin.php/file?path=<?php echo $path;?>&page=<?php echo $pagecount ?>">尾页</a> </span>
            <?php } ?>
            跳到<select onchange="javascript:location.href = '?path=<?php echo $path;?>&page=' + this.options[this.selectedIndex].value">
                <?php for ($i = 1; $i <= $pagecount; $i++) { ?>
                    <option value="<?php echo $i ?>" ><?php echo $i ?></option>
                <?php } ?>
            </select>页
        </div>
        <!--分页结束-->
    </div>
</form>
<script src="/static/bk/js/table.js" type="text/javascript"></script>
<?php $this->load->view('layout/footer'); ?>
